//
//  htvsample.m
//  PHApp
//
//  Created by zhangwq on 16/4/7.
//  Copyright © 2016年 HT. All rights reserved.
//

#import "htvsample.h"
#import "HTFrameKit.h"
#import "HTSysKit.h"
#import "HTFrameConvert.h"
#import "UIImageView+WebCache.h"

@interface htvsample (){
    CGFloat width;
    CGFloat height;
    UIView *uv;
    NSMutableArray *sampleArray;
    int pageNum;//当前显示数据页 0/1:0表示刷新，1表示加载更多
    int page;
    UIColor *backcolor;
    UIColor *backcolor2;
    UIView *sampleview;
    CGFloat buttomHeight;
    UIView *chooseview;
    UITextField *txtkh;
    UITextField *txtzh;
    UITextField *txtxm;
    UIImageView *photo;
}

@property (nonatomic, strong) NSOperationQueue *queue;

@end

@implementation htvsample


- (NSOperationQueue *)queue {
    if (!_queue) _queue = [[NSOperationQueue alloc] init];
    return _queue;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    CGRect rect = [[UIScreen mainScreen] bounds];
    CGSize size = rect.size;
    width = size.width;
    height = size.height;
    
    sampleArray=[NSMutableArray array];
    page=1;
    
    
    //上拉，下拉刷新
    
    
    self.tableView.pullDelegate = self;
    if( ([[[UIDevice currentDevice] systemVersion] doubleValue]>=7.0)) {
        self.edgesForExtendedLayout = UIRectEdgeNone;
        self.extendedLayoutIncludesOpaqueBars = NO;
        self.modalPresentationCapturesStatusBarAppearance = NO;
    }
    
    self.tableView.delegate=self;
    self.tableView.dataSource=self;
    
    self.tableView.separatorStyle=NO;
    
    backcolor=[UIColor colorWithRed:249.0/255.0 green:249.0/255.0 blue:249.0/255.0 alpha:1.0];
    
    backcolor2=[UIColor colorWithRed:180.0/255.0 green:180.0/255.0 blue:180.0/255.0 alpha:1.0];
    
    [self bindList];
    
    self.navigationController.navigationBar.backgroundColor=[UIColor whiteColor];
    self.tabBarController.tabBar.backgroundColor=[UIColor whiteColor];
    
    
    sampleview=[[UIView alloc]initWithFrame:CGRectMake(0, height-153, width, 40)];
    sampleview.backgroundColor=[UIColor colorWithRed:91.0/255.0 green:138.0/255.0 blue:218.0/255.0 alpha:1.0];
    [self.view addSubview:sampleview];
    
    UILabel *lbsample=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, width, 40)];
    lbsample.text=@"开始选样";
    lbsample.textColor=[UIColor whiteColor];
    lbsample.font=[UIFont fontWithName:@"Arial" size:16.0];
    lbsample.textAlignment=UITextAlignmentCenter;
    [sampleview addSubview:lbsample];
    
    
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(sampleAction:)];
    [sampleview addGestureRecognizer:tapGesture];
    
    sampleview.hidden=YES;
    

}


//开始选样
-(void)sampleAction:(UITapGestureRecognizer*)sender{
    chooseview=[[UIView alloc]initWithFrame:CGRectMake(0, buttomHeight, width, height)];
    chooseview.backgroundColor=[UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0];
    [self.view addSubview:chooseview];
    self.tableView.scrollEnabled=NO;
    
    //拍照
    photo=[[UIImageView alloc]initWithFrame:CGRectMake(width/2-30, 20, 60, 60)];
    photo.image=[UIImage imageNamed:@"pz"];
    [photo setClipsToBounds:YES];
    [photo setContentMode:UIViewContentModeScaleAspectFill];
    photo.layer.masksToBounds=YES;
    photo.userInteractionEnabled=YES;
    photo.layer.cornerRadius=4;
    [chooseview addSubview:photo];
    
    UITapGestureRecognizer *photoGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(photoAction:)];
    [photo addGestureRecognizer:photoGesture];
    
    //展会
    UILabel *lbzh=[[UILabel alloc]initWithFrame:CGRectMake(width/2-140, 110, 200, 30)];
    lbzh.text=@"展会:";
    lbzh.textColor=[UIColor colorWithRed:150.0/255.0 green:150.0/255.0 blue:150.0/255.0 alpha:1.0];
    lbzh.font=[UIFont fontWithName:@"Arial" size:15.0];
    [chooseview addSubview:lbzh];
    
    txtzh=[[UITextField alloc]initWithFrame:CGRectMake(width/2-90, 110, 180, 30)];
    txtzh.layer.cornerRadius=4;
    txtzh.font=[UIFont fontWithName:@"Arial" size:12.0];
    txtzh.layer.borderColor=[UIColor colorWithRed:150.0/255.0 green:150.0/255.0 blue:150.0/255.0 alpha:1.0].CGColor;
    txtzh.layer.borderWidth=0.6;
    txtzh.textAlignment=UITextAlignmentCenter;
    [chooseview addSubview:txtzh];
    
    UIImageView *phAdd=[[UIImageView alloc]initWithFrame:CGRectMake(width/2+110, 110, 30, 30)];
    phAdd.image=[UIImage imageNamed:@"zen"];
    [phAdd setClipsToBounds:YES];
    [phAdd setContentMode:UIViewContentModeScaleAspectFill];
    phAdd.layer.masksToBounds=YES;
    phAdd.userInteractionEnabled=YES;
    [chooseview addSubview:phAdd];
    //客户
    UILabel *lbkh=[[UILabel alloc]initWithFrame:CGRectMake(width/2-140, 150, 200, 30)];
    lbkh.text=@"客户:";
    lbkh.textColor=[UIColor colorWithRed:150.0/255.0 green:150.0/255.0 blue:150.0/255.0 alpha:1.0];
    lbkh.font=[UIFont fontWithName:@"Arial" size:15.0];
    [chooseview addSubview:lbkh];
    
    txtkh=[[UITextField alloc]initWithFrame:CGRectMake(width/2-90, 150, 180, 30)];
    txtkh.layer.cornerRadius=4;
    txtkh.font=[UIFont fontWithName:@"Arial" size:12.0];
    txtkh.layer.borderColor=[UIColor colorWithRed:150.0/255.0 green:150.0/255.0 blue:150.0/255.0 alpha:1.0].CGColor;
    txtkh.layer.borderWidth=0.6;
    txtkh.textAlignment=UITextAlignmentCenter;
    [chooseview addSubview:txtkh];
    
    UIImageView *phAdd2=[[UIImageView alloc]initWithFrame:CGRectMake(width/2+110, 150, 30, 30)];
    phAdd2.image=[UIImage imageNamed:@"zen"];
    [phAdd2 setClipsToBounds:YES];
    [phAdd2 setContentMode:UIViewContentModeScaleAspectFill];
    phAdd2.layer.masksToBounds=YES;
    phAdd2.userInteractionEnabled=YES;
    [chooseview addSubview:phAdd2];
    //姓名
    UILabel *lbxm=[[UILabel alloc]initWithFrame:CGRectMake(width/2-140, 190, 200, 30)];
    lbxm.text=@"姓名:";
    lbxm.textColor=[UIColor colorWithRed:150.0/255.0 green:150.0/255.0 blue:150.0/255.0 alpha:1.0];
    lbxm.font=[UIFont fontWithName:@"Arial" size:15.0];
    [chooseview addSubview:lbxm];
    
    txtxm=[[UITextField alloc]initWithFrame:CGRectMake(width/2-90, 190, 180, 30)];
    txtxm.layer.cornerRadius=4;
    txtxm.font=[UIFont fontWithName:@"Arial" size:12.0];
    txtxm.layer.borderColor=[UIColor colorWithRed:150.0/255.0 green:150.0/255.0 blue:150.0/255.0 alpha:1.0].CGColor;
    txtxm.layer.borderWidth=0.6;
    txtxm.textAlignment=UITextAlignmentCenter;
    [chooseview addSubview:txtxm];
    
    UIImageView *phAdd3=[[UIImageView alloc]initWithFrame:CGRectMake(width/2+110, 190, 30, 30)];
    phAdd3.image=[UIImage imageNamed:@"zen"];
    [phAdd3 setClipsToBounds:YES];
    [phAdd3 setContentMode:UIViewContentModeScaleAspectFill];
    phAdd3.layer.masksToBounds=YES;
    phAdd3.userInteractionEnabled=YES;
    [chooseview addSubview:phAdd3];
    
    //开始选样 取消
    UIButton *btnKS=[[UIButton alloc]initWithFrame:CGRectMake(width/2-90, 240, 70, 30)];
    [btnKS setTitle:@"开始选样" forState:UIControlStateNormal];
    [btnKS setTitleColor:[UIColor colorWithRed:106.0/255.0 green:160.0/255.0 blue:236.0/255.0 alpha:1.0]  forState:UIControlStateNormal];
    btnKS.layer.cornerRadius=4;
    btnKS.layer.borderWidth=0.6;
    btnKS.layer.borderColor=[UIColor colorWithRed:106.0/255.0 green:160.0/255.0 blue:236.0/255.0 alpha:1.0] .CGColor;
    btnKS.font=[UIFont fontWithName:@"Arial" size:13.0];
    [btnKS addTarget:self action:@selector(ksxyAction:) forControlEvents:UIControlEventTouchUpInside];
    [chooseview addSubview:btnKS];
    
    UIButton *btnQX=[[UIButton alloc]initWithFrame:CGRectMake(width/2+20, 240, 70, 30)];
    [btnQX setTitle:@"取消" forState:UIControlStateNormal];
    [btnQX setTitleColor:[UIColor colorWithRed:106.0/255.0 green:160.0/255.0 blue:236.0/255.0 alpha:1.0] forState:UIControlStateNormal];
    btnQX.layer.cornerRadius=4;
    btnQX.layer.borderWidth=0.6;
    btnQX.layer.borderColor=[UIColor colorWithRed:106.0/255.0 green:160.0/255.0 blue:236.0/255.0 alpha:1.0] .CGColor;
    btnQX.font=[UIFont fontWithName:@"Arial" size:13.0];
    [btnQX addTarget:self action:@selector(qxAction:) forControlEvents:UIControlEventTouchUpInside];
    [chooseview addSubview:btnQX];
    
    
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(chooseAction:)];
    [chooseview addGestureRecognizer:tapGesture];

}

//关闭选样窗口
-(void)qxAction:(UIButton*)sender{
    
    [chooseview removeFromSuperview];
    self.tableView.scrollEnabled=YES;
    
}

//开始选样
-(void)ksxyAction:(UIButton*)sender{
    
    NSString *storyboard=@"SampleInfo";
    NSString *Identifier=@"SampleInfo";
    UIStoryboard *valueView = [UIStoryboard storyboardWithName:storyboard bundle:nil];
    UIViewController *uv=[valueView instantiateViewControllerWithIdentifier:Identifier];
    UINavigationController *baNavigation = [[UINavigationController alloc] initWithRootViewController:uv];
    [self presentModalViewController:baNavigation animated:YES];
    
    //返回
    
}



-(void)chooseAction:(UITapGestureRecognizer*)sender{
    [txtkh resignFirstResponder];
    [txtxm resignFirstResponder];
    [txtzh resignFirstResponder];
}


-(void)photoAction:(UITapGestureRecognizer*)sender{
    [txtkh resignFirstResponder];
    [txtxm resignFirstResponder];
    [txtzh resignFirstResponder];
    
    [self openCraml];
    
}



#pragma 照片
-(void)openCraml{
    
    UIActionSheet *actionSheet = [[UIActionSheet alloc]
                                  initWithTitle:@"请选择照片来源"
                                  delegate:self
                                  cancelButtonTitle:@"取消"
                                  destructiveButtonTitle:@"拍    照"
                                  otherButtonTitles:@"我的相册",nil];
    actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
    [actionSheet showInView:self.view];
    
}



-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0) {//拍照
        [self openCamera];
    }else if (buttonIndex == 1) {//我的相册
        [self openPhotoLibrary];
    }else if(buttonIndex == 2) {//取消
        
    }
    
}


-(void)openCamera{
    BOOL hasCamera = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];//判断照相机是否可用（是否有摄像头）
    if(hasCamera == YES)
    {
        UIImagePickerController *picker = [[UIImagePickerController alloc] init];
        picker.sourceType = UIImagePickerControllerSourceTypeCamera;
        picker.delegate = self;
        picker.allowsEditing = YES; //是否可编辑
        [self presentModalViewController:picker animated:YES];
        
    }
    else
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"你没有摄像头" delegate:nil cancelButtonTitle:@"ok!" otherButtonTitles:nil];
        [alert show];
        
    }
}


-(void)openPhotoLibrary{
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    picker.delegate = self;
    picker.allowsEditing = YES; //是否可编辑
    [self presentModalViewController:picker animated:YES];
}


- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage *img=[info objectForKey:@"UIImagePickerControllerOriginalImage"];
    photo.image=img;
    photo.frame=CGRectMake(width/2-90, 5, 180, 100);
    [self dismissModalViewControllerAnimated:YES];
    
    
}




-(void)bindList{
    
    NSString *serverUrl=[[NSString alloc]initWithFormat:@"%@\/%@\/",[HTSysParam erpServer],[HTSysParam erpVirDir]];
    HTFrameNet *htnet=[[HTFrameNet alloc] initWithServerUrl:serverUrl];
    NSString *pagenumStr=[[NSString alloc]initWithFormat:@"%i",page];
    NSDictionary *dict = @{@"queryStr":@"",@"pagernationVo": @{@"currPage":pagenumStr,@"pageSize": @10}};
    [htnet hmNetWCFmethodName:@"web/sample/queryDataSampleByQueryStr" andDic:dict complete:^(NSString *backstr)
     {
         
         
         NSDictionary *formdict=[HTFrameNet hmConvertDictFromJsonStr:backstr];//表单单头
         NSDictionary *body=[formdict objectForKey:@"body"];
         if(body!=nil){
             NSDictionary *resultdt2=[body objectForKey:@"DataSample"];
             NSMutableArray *resultdt=[resultdt2 objectForKey:@"data"];
             if (pageNum==0) {//刷新数据在头部插入
                 for (int i=[resultdt count]-1; i>=0; i--) {
                     [sampleArray insertObject:[resultdt objectAtIndex:i] atIndex:0];
                 }
             }
             else if (pageNum==1){//加载历史，在尾部插入
                 for (int i=0; i<[resultdt count]; i++) {
                     [sampleArray addObject:[resultdt objectAtIndex:i]];
                     
                 }
                 
             }
             
             if([resultdt count]==0&&page>1)
             {
                 page=page-1;
             }
             
             [self.tableView reloadData];
             
             sampleview.hidden=NO;
             
             
             
         }
         
         
     }];

    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if(section==0){
        return 1;
    }
    else{
        return [sampleArray count];
    }
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if([indexPath section]==0){
        return 20.0;
    }
    else{
        if([indexPath row]<[sampleArray count]-1){
            return 130.0;
        }
        else{
            return 150.0;
        }
        
    }
}





- ( UITableViewCell *)tableView:( UITableView *)tableView cellForRowAtIndexPath:( NSIndexPath *)indexPath{
    
    NSString *cellId = @"cellname" ;
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier :cellId];
    if (cell == nil ) {
        cell = [[ UITableViewCell alloc ] initWithStyle : UITableViewCellStyleDefault reuseIdentifier :cellId] ;
    }
    
    uv=[[UIView alloc]initWithFrame:CGRectMake(0, 0, width, 130)];
    
    if([indexPath section]==0){
        uv=[[UIView alloc]initWithFrame:CGRectMake(0, 0, width, 20)];
        uv.backgroundColor=backcolor;
        
        
        UIView *line=[[UIView alloc]initWithFrame:CGRectMake(20, 0, width, 20)];
        line.backgroundColor=backcolor;
        [uv addSubview:line];
    }
    else{
        if([indexPath row]<[sampleArray count]-1){
            uv=[[UIView alloc]initWithFrame:CGRectMake(0, 0, width, 130)];
        }
        else{
            uv=[[UIView alloc]initWithFrame:CGRectMake(0, 0, width, 150)];
        }
        
        NSDictionary *dict=[[NSDictionary alloc]init];
        if([sampleArray count]>[indexPath row
                                ]){
            
            dict=[sampleArray objectAtIndex:[indexPath row]];
            
            UILabel *lbvendorname=[[UILabel alloc]initWithFrame:CGRectMake(120, 10, 200, 20)];
            lbvendorname.text=[[NSString alloc]initWithFormat:@"%@",[self checkValue:[dict objectForKey:@"vendorName"]] ];
            lbvendorname.textColor=[UIColor blackColor];
            lbvendorname.font=[UIFont fontWithName:@"Arial" size:14.0];
            [uv addSubview:lbvendorname];
            
            UILabel *lbformDate=[[UILabel alloc]initWithFrame:CGRectMake(width-100, 10, 100, 20)];
            lbformDate.text=[[NSString alloc]initWithFormat:@"%@",[self checkDate:[dict objectForKey:@"formDate"]] ];
            lbformDate.textColor=backcolor2;
            lbformDate.font=[UIFont fontWithName:@"Arial" size:10.0];
            lbformDate.textAlignment=UITextAlignmentRight;
            [uv addSubview:lbformDate];
            
            
            UILabel *lbcontactOPName=[[UILabel alloc]initWithFrame:CGRectMake(120, 40, 300, 20)];
            lbcontactOPName.text=[[NSString alloc]initWithFormat:@"联系人：%@",[self checkValue:[dict objectForKey:@"contactOPName"]] ];
            lbcontactOPName.textColor=backcolor2;
            lbcontactOPName.font=[UIFont fontWithName:@"Arial" size:12.0];
            [uv addSubview:lbcontactOPName];
            
            UILabel *lbcontactTel=[[UILabel alloc]initWithFrame:CGRectMake(120, 60, 300, 20)];
            lbcontactTel.text=[[NSString alloc]initWithFormat:@"联系电话：%@",[self checkValue:[dict objectForKey:@"contactTel"]] ];
            lbcontactTel.textColor=backcolor2;
            lbcontactTel.font=[UIFont fontWithName:@"Arial" size:12.0];
            [uv addSubview:lbcontactTel];
            
            UILabel *lbsaleOPID=[[UILabel alloc]initWithFrame:CGRectMake(120, 80, 300, 20)];
            lbsaleOPID.text=[[NSString alloc]initWithFormat:@"业务员：%@",[self checkValue:[dict objectForKey:@"saleOPID"]] ];
            lbsaleOPID.textColor=backcolor2;
            lbsaleOPID.font=[UIFont fontWithName:@"Arial" size:12.0];
            [uv addSubview:lbsaleOPID];
            
            
            
            UIImageView *iv=[[UIImageView alloc]initWithFrame:CGRectMake(30,15, 80,80)];
            iv.accessibilityLabel=@"http://7xshdz.com2.z0.glb.clouddn.com/20130827084459683.jpg";
            [iv setClipsToBounds:YES];
            [iv setContentMode:UIViewContentModeScaleAspectFill];
            iv.layer.masksToBounds=YES;
            iv.layer.cornerRadius = 4;
            iv.userInteractionEnabled=YES;
            [self downloadImg:iv];
            [uv addSubview:iv];
            
            
            
            
            
            
            UIView *line=[[UIView alloc]initWithFrame:CGRectMake(20, 110, width, 20)];
            line.backgroundColor=backcolor;
            [uv addSubview:line];
            
            
            UITapGestureRecognizer *cellGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(sampledetailAction:)];
            cellGesture.accessibilityLabel=[dict objectForKey:@"id"];
            [uv addGestureRecognizer:cellGesture];
            
            
        }

    }
    
    
    
    
    
    

    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    cell.accessoryView=uv;
    
    
    
    return cell;
}



-(void)sampledetailAction:(UITapGestureRecognizer*)sender{
    NSString *storyboard=@"SampleDetail";
    NSString *Identifier=@"SampleDetail";
    UIStoryboard *valueView = [UIStoryboard storyboardWithName:storyboard bundle:nil];
    UIViewController *uv=[valueView instantiateViewControllerWithIdentifier:Identifier];
    [uv setValue:sender.accessibilityLabel forKey:@"formid"];
    UINavigationController *baNavigation = [[UINavigationController alloc] initWithRootViewController:uv];
    [self presentModalViewController:baNavigation animated:YES];
    
    //返回
}





-(NSString *)checkValue:(id)value{
    if(value==nil||value==[NSNull null]){
        return @"-";
    }
    else{
        return value;
    }
}

-(NSString *)checkDate:(id)value{
    NSString *datestr=@"-";
    NSArray *aTest = [value componentsSeparatedByString:@" "];
    if([aTest count]>0){
        datestr=[aTest objectAtIndex:0];
    }
    return datestr;
}




- (void)downloadImg:(UIImageView *)theImageView {
    
    NSString *imageName=[[NSString alloc]initWithFormat:@"%@?imageView2/2/w/200",theImageView.accessibilityLabel];
    NSURL *imagePath = [NSURL URLWithString:imageName];
    [self.queue addOperationWithBlock: ^{
        
        //在主线程中更新UI
        [[NSOperationQueue mainQueue] addOperationWithBlock: ^{
            
            [theImageView sd_setImageWithURL:imagePath placeholderImage:[UIImage imageNamed:@"nopic"]];
            
            
            
        }];
    }];
}




#pragma 加载更多
//刷新数据
- (void) refreshTable
{
    pageNum=0;//刷新
    page=1;
    sampleArray=[NSMutableArray array];
    [self bindList];
    self.tableView.pullLastRefreshDate = [NSDate date];
    self.tableView.pullTableIsRefreshing = NO;
}


//加载更多数据
- (void) loadMoreDataToTable
{
    
    pageNum=1;//加载历史
    page=page+1;
    //读取服务端数据
    [self bindList];
    
    self.tableView.pullTableIsLoadingMore = NO;
    
}





#pragma mark - PullTableViewDelegate协议方法
-(void)pullTableViewDidTriggerRefresh:(PullTableView *)pullTableView
{
    @try {
        [self performSelector:@selector(refreshTable) withObject:nil afterDelay:1];
    }
    @catch (NSException *exception) {
        
        NSLog(@"HTINFO:%@",exception);
    }
    @finally {
    }
    
}

-(void)pullTableViewDidTriggerLoadMore:(PullTableView *)pullTableView
{
    [self performSelector:@selector(loadMoreDataToTable) withObject:nil afterDelay:1];
}


-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    CGPoint scroll=scrollView.contentOffset;
    buttomHeight=scroll.y;
    sampleview.frame=CGRectMake(0, buttomHeight+height-153, width, 40);
}



- (IBAction)searchAction:(UIButton *)sender {
    NSString *storyboard=@"SampleQuery";
    NSString *Identifier=@"SampleQuery";
    UIStoryboard *valueView = [UIStoryboard storyboardWithName:storyboard bundle:nil];
    UIViewController *uv=[valueView instantiateViewControllerWithIdentifier:Identifier];
    UINavigationController *baNavigation = [[UINavigationController alloc] initWithRootViewController:uv];
    [self presentModalViewController:baNavigation animated:YES];
    
    //返回

}
@end
